################################################################################
#
# recalbox-romfs-snes
#
################################################################################

# Package generated with :
# ./scripts/linux/empack.py --force --system snes --extension '.smc .sfc .SMC .SFC .mgd .MGD .zip .ZIP .7z .7Z' --fullname 'Super Nintendo Entertainment System' --platform snes --theme snes 2:libretro:snes9x2002:BR2_PACKAGE_LIBRETRO_SNES9X2002 3:libretro:snes9x2005:BR2_PACKAGE_LIBRETRO_SNES9X2005 4:libretro:snes9x2010:BR2_PACKAGE_LIBRETRO_SNES9X2010 5:libretro:snes9x:BR2_PACKAGE_LIBRETRO_SNES9X 1:pisnes:pisnes:BR2_PACKAGE_PISNES

# Name the 3 vars as the package requires
RECALBOX_ROMFS_SNES_SOURCE = 
RECALBOX_ROMFS_SNES_SITE = 
RECALBOX_ROMFS_SNES_INSTALL_STAGING = NO
# Set the system name
SYSTEM_NAME_SNES = snes
SYSTEM_XML_SNES = $(@D)/$(SYSTEM_NAME_SNES).xml
# System rom path
SOURCE_ROMDIR_SNES = $(RECALBOX_ROMFS_SNES_PKGDIR)/roms

# CONFIGGEN_STD_CMD is defined in recalbox-romfs, so take good care that
# variables are global across buildroot


ifneq ($(BR2_PACKAGE_LIBRETRO_SNES9X2002)$(BR2_PACKAGE_LIBRETRO_SNES9X2005)$(BR2_PACKAGE_LIBRETRO_SNES9X2010)$(BR2_PACKAGE_LIBRETRO_SNES9X)$(BR2_PACKAGE_PISNES),)
define CONFIGURE_MAIN_SNES_START
	$(call RECALBOX_ROMFS_CALL_ADD_SYSTEM,$(SYSTEM_XML_SNES),Super Nintendo Entertainment System,$(SYSTEM_NAME_SNES),.smc .sfc .SMC .SFC .mgd .MGD .zip .ZIP .7z .7Z,snes,snes)
endef

ifneq ($(BR2_PACKAGE_LIBRETRO_SNES9X2002)$(BR2_PACKAGE_LIBRETRO_SNES9X2005)$(BR2_PACKAGE_LIBRETRO_SNES9X2010)$(BR2_PACKAGE_LIBRETRO_SNES9X)$(BR2_PACKAGE_PISNES),)
define CONFIGURE_SNES_PISNES_START
	$(call RECALBOX_ROMFS_CALL_START_EMULATOR,$(SYSTEM_XML_SNES),pisnes)
endef
ifeq ($(BR2_PACKAGE_PISNES),y)
define CONFIGURE_SNES_PISNES_PISNES_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_SNES),pisnes,1)
endef
endif

define CONFIGURE_SNES_PISNES_END
	$(call RECALBOX_ROMFS_CALL_END_EMULATOR,$(SYSTEM_XML_SNES))
endef
endif

ifneq ($(BR2_PACKAGE_LIBRETRO_SNES9X2002)$(BR2_PACKAGE_LIBRETRO_SNES9X2005)$(BR2_PACKAGE_LIBRETRO_SNES9X2010)$(BR2_PACKAGE_LIBRETRO_SNES9X)$(BR2_PACKAGE_PISNES),)
define CONFIGURE_SNES_LIBRETRO_START
	$(call RECALBOX_ROMFS_CALL_START_EMULATOR,$(SYSTEM_XML_SNES),libretro)
endef
ifeq ($(BR2_PACKAGE_LIBRETRO_SNES9X2005),y)
define CONFIGURE_SNES_LIBRETRO_SNES9X2005_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_SNES),snes9x2005,3)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_SNES9X2010),y)
define CONFIGURE_SNES_LIBRETRO_SNES9X2010_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_SNES),snes9x2010,4)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_SNES9X),y)
define CONFIGURE_SNES_LIBRETRO_SNES9X_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_SNES),snes9x,5)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_SNES9X2002),y)
define CONFIGURE_SNES_LIBRETRO_SNES9X2002_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_SNES),snes9x2002,2)
endef
endif

define CONFIGURE_SNES_LIBRETRO_END
	$(call RECALBOX_ROMFS_CALL_END_EMULATOR,$(SYSTEM_XML_SNES))
endef
endif



define CONFIGURE_MAIN_SNES_END
	$(call RECALBOX_ROMFS_CALL_END_SYSTEM,$(SYSTEM_XML_SNES),$(SOURCE_ROMDIR_SNES),$(@D))
endef
endif

define RECALBOX_ROMFS_SNES_CONFIGURE_CMDS
	$(CONFIGURE_MAIN_SNES_START)
	$(CONFIGURE_SNES_PISNES_START)
	$(CONFIGURE_SNES_PISNES_PISNES_DEF)
	$(CONFIGURE_SNES_PISNES_END)
	$(CONFIGURE_SNES_LIBRETRO_START)
	$(CONFIGURE_SNES_LIBRETRO_SNES9X2005_DEF)
	$(CONFIGURE_SNES_LIBRETRO_SNES9X2010_DEF)
	$(CONFIGURE_SNES_LIBRETRO_SNES9X_DEF)
	$(CONFIGURE_SNES_LIBRETRO_SNES9X2002_DEF)
	$(CONFIGURE_SNES_LIBRETRO_END)
	$(CONFIGURE_MAIN_SNES_END)
endef

$(eval $(generic-package))
